#ifndef __CMATH_H__
#define __CMATH_H__


#include "StdDefs.h"


class CMath 
{
public:
	//
	static int32			Abs( int32 val );
	static int32			Max( int32 val1, int32 val2 );
	static int32			Min( int32 val1, int32 val2 );

	/*
	*  Integer Square Root function
	*  Contributors include Arne Steinarson for the basic approximation idea, Dann 
	*  Corbit and Mathew Hendry for the first cut at the algorithm, Lawrence Kirby 
	*  for the rearrangement, improvements and range optimization and Paul Hsieh 
	*  for the round-then-adjust idea.
	*
	*  Source: http://www.azillionmonkeys.com/qed/sqroot.html
	*  (originally posted on comp.graphics.algorithms)
	*/
	static int32			Sqrt( int32 val );
};





inline
int32 CMath::Abs( int32 val )
{
	return val > 0 ? val : -val;
}


inline
int32 CMath::Max( int32 val1, int32 val2 )
{
	return ( val1 > val2 )? val1 : val2;
}


inline
int32 CMath::Min( int32 val1, int32 val2 )
{
	return ( val1 < val2 )? val1 : val2;
}


#endif // #define __CMATH_H__
